<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 编写函数 camelize(str) 将诸如 “my-short-string” 之类的由短划线分隔的单词变成骆驼式的 “myShortString”
        // 即：删除所有短横线，并将短横线后的每一个单词的首字母变为大写。
        function camelize(str) {
            let arr = str.split("-");
            console.log(arr);//delete
            let a = [arr[0]];
            for (let i = 0; i < arr.length; i++) {
                if (i != 0) {
                    let num = arr[i][0].toUpperCase();
                    let b = arr[i].replace(arr[i][0], num);     //replace,替换收首字母，改为怒骂，num为上一行改为大写的数字；
                    let c = a.push(b);
                }
            }
            console.log(a.join(''));
        }
        camelize("my-short-string");
        camelize("background-color"); // 'backgroundColor';
        camelize("list-style-image"); // 'listStyleImage';
        camelize("-webkit-transition"); // 'WebkitTransition';
    </script>
</body>

</html>